#pragma once

#include "GSE_Net.h"
#include "GSE_CSession.h"

using namespace boost;
using namespace boost::asio;
namespace GSE
{
	class CConnector :public enable_shared_from_this<CConnector> , public IConnector
	{
	public:
		CConnector(io_service & ios);
		~CConnector();

		virtual void Connect(const char * strIP, const char * strPort);
		virtual void SetSessionCallback(ISessionCallback * lpCallback);
		virtual ISession* GetSession();
		virtual uint Run();
	private:
		void OnConnected(const system::error_code& errCode);
		void AsyncConnect();
		void AsyncResolve(const system::error_code& errCode,ip::tcp::resolver::iterator iterator);

	private:
		io_service&			m_IOService;
		CSession::pointer	m_lpSession;
		ip::tcp::endpoint	m_EndPoint;
		ip::tcp::resolver	m_tcpResolver;
	};
}